var SdsAsmt = {
    asmtInfo: null,//评估字典信息
    asmtScore: 0, // 分数
    asmtLevel: "", // 等级
    evalId: 0, // 评估id
    sdsAsmtData: [],
    hasNodeFlag: 0,
    layerIndex: -1,
    evalNode: "",
    sdsAsmtAutoData: [],
    eventDisplayWay: 0,		//评估摘要显示方式 0节点水平步骤 1分数趋势图
};


function getNodeInfo(evalId) {
    $('span.auto').remove();

    $('div').find('.dic-desc-selected').removeClass('dic-desc-selected');
    var ajax = new $ax("/api/sdstool/getNodeInfo", function (data) {
        var l = data.length;
        for (let i = 0; i < data.length; i++) {
            var itemId = data[i].assessmentEntryId;
            $("#" + itemId).addClass("dic-desc-selected");
            if (data[i].manual === 0) {
                var x = "<span id=" + data[i].id + " class='auto' style='position: absolute;right: 100px;'>A</span>";
                document.getElementById(itemId).innerHTML += x;
            } else {
                var x = "<span id=" + data[i].id + " class='auto' style='position: absolute;right: 100px;'>H</span>";
                document.getElementById(itemId).innerHTML += x;
            }
            getItemKeyFrom(data[i].id, "");
        }
    }, function (data) {
    });
    var params = {};
    params.patientId = $("#patientId").val();
    params.entityId = $("#entityId").val();
    params.asmtId = $("#asmId").val();
    params.evalId = $("#evalId").val();
    ajax.set(params);
    ajax.start();
}

function getItemKeyFrom(evalItemId, evalHisId) {
    var param = {};
    var ajax = new $ax("/api/sdstool/getItemKeyFrom", function (data) {
        if (data != null) {
            var titleStr = (data) + "<br>";
            var indexItem = null;

            if (evalItemId != "") {
                $("#" + evalItemId).hover(function () {
                    indexItem = layer.tips(titleStr, $("#" + evalItemId), {
                        tips: 3,
                        area: ['250px', 'auto'],
                        time: 5000
                    });
                }, function () {
                    layer.close(indexItem);
                });
            }

            if (evalHisId != "") {
                $("#" + evalHisId).hover(function () {
                    indexItem = layer.tips(titleStr, $("#" + evalHisId), {
                        tips: 3,
                        area: ['250px', 'auto'],
                        time: 5000
                    });
                }, function () {
                    layer.close(indexItem);
                });
            }

        }
    }, function (data) {
    });
    param.evalItemId = evalItemId;
    param.evalHisId = evalHisId;
    ajax.set(param);
    ajax.start();
}

function loadAsmtNodes() {
    // 获取阶段信息
    var ajax = new $ax("/api/sdstool/getAsmtNode", function (data) {
        var l = data.length;
        var contextStr = "<div class='itemNode' id='1' score='' level=''><div style='text-align: center;font-size: 18px;'></div></div>";
        for (let i = 0; i < l; i++) {
            var item = {};
            var eval = data[i];
            var evalId = eval.evalId;
            var evalNode = eval.nodeType;
            var nodeId = eval.nodeId;
            var evalLevel = eval.evalLevel;
            var evalScore = eval.evalScore;
            var nodeStr = "";
            if (evalNode != undefined && evalNode != "") {
                nodeStr = "<div class=\"node\" id=\"" + nodeId + "\">节点：" + evalNode + "</div>"
            }
            contextStr += "<div class='itemNode' id='" + evalId + "' score=" + eval.evalScore + " level=\"" + eval.evalLevel + "\">" + nodeStr + "<div>评分：" + eval.evalScore + "</div><div>日期：" + eval.evalDate.substring(0, 16) + "</div></div>";
            if (i == 0) {
                SdsAsmt.asmtScore = eval.evalScore;
            }
        }
        $(".evalNodeBlock").html(contextStr);

        $("#eventChart").hide();

        $(".itemNode").on('click', function () {
            var evalId = $(this).attr("id");
            var score = eval.evalScore;
            var level = eval.evalLevel;
            SdsAsmt.evalId = evalId
            SdsAsmt.evalNode = evalNode
            if (evalId != 0){
                $("#print").show();
                getNodeInfo(evalId);
                $('#asmtScore').text(score);
                var clazz = returnLevelClass(level);
                if(level !=""){
                    $('#asmtResult').text("("+level+")").removeClass().addClass(clazz);
                } else {
                    $('#asmtResult').text("");
                }
                $(".itemNode").removeClass("active");
                $(this).addClass("active");
                var nodeId = $(this).find(".node").attr("id");
                $("#nodeType").combobox("setValue", nodeId);
                $("#nodeType").combobox("disable");
            }else {
                $("#print").hide();
                getAutoNodeInfo();
                $('#asmtScore').text(score);
                var clazz = returnLevelClass(level);
                if(level !=""){
                    $('#asmtResult').text("("+level+")").removeClass().addClass(clazz);
                } else {
                    $('#asmtResult').text("");
                }
                $(".itemNode").removeClass("active");
                $(this).addClass("active");
                var nodeId = $(this).find(".node").attr("id");
                $("#nodeType").combobox("setValue", nodeId);
                $("#nodeType").combobox("enable");
            }
        })
        // 默认选中新建节点
        $(".itemNode[id='1']").click();
    }, function (data) {
    });
    var params = {};
    params.patientId = $("#patientId").val();
    params.entityId = $("#entityId").val();
    params.asmtId = $("#asmtId").val();
    params.evalId = $("#evalId").val();
    ajax.set(params);
    ajax.setAsync(true);
    ajax.start();
}


/**
 * 判断不同类型量表级别描述
 * @param score
 * @returns judgeRiskLevel
 */
function judgeLevel(score) {
    var levelDesc = "";
    score = parseInt(score);
    var dicLevelInfo = SdsAsmt.asmtInfo.levelRange;
    for (var i = 0; i < dicLevelInfo.length; i++) {
        var minValue = parseInt(dicLevelInfo[i].minVal);
        var maxValue = parseInt(dicLevelInfo[i].maxVal);
        if (score >= minValue && score <= maxValue) {
            levelDesc = dicLevelInfo[i].level;
        }
    }
    return levelDesc;
}

/**
 * 评估节点切换水平步骤和分数趋势图
 */
function evalEventChange() {
    SdsAsmt.eventDisplayWay = SdsAsmt.eventDisplayWay == 0 ? 1 : 0;
    if (SdsAsmt.eventDisplayWay == 0) {//水平步骤
        $("#hisStep").show();
        $("#eventChart").hide();
    } else {//分数趋势图
        $("#hisStep").hide();
        $("#eventChart").show();
    }
}

/**
 * 计算分数和结果  每次选中/填写评估表，计算当前所得分值
 */
function calVal(sheetCode) {
    //初始化评估得分、值、评分字典
    var tscore = 0, tval = "", selectdicstr = "";
    // obj.ScoreArr[obj.EQCItemCode]=""
    $('div').find('.dic-desc-selected').each(function (i, v) {
        var xscore = $(this).attr('data-score');
        selectdicstr = selectdicstr + "^" + $(this).attr('id');
        if (!isNaN(parseFloat(xscore))) {
            //分值评定，分值相加
            tscore = tscore + parseFloat(xscore);
        } else {
            //等级评估，直接显示等级描述
            tscore = xscore
            //如果有计算表达式，按照计算公式进行转换
            texp = $(this).attr('data-calc');
            if (texp) {
                texp.replace('this', xscore);
                tval = eval('texp');
            }
        }
    })

    $('.dic-input').each(function (i, v) {
        texp = $(this).attr('data-calc')
        xscore = $(this).val()
        if (xscore != "") {
            if (texp) {
                texp = texp.replace('this', xscore)
                //计算表达式结果值 保留2位小数
                xscore = eval(texp).toFixed(2)
            }
            tscore = tscore + Number(xscore)
            selectdicstr = selectdicstr + "^" + $(this).attr('id') + "`" + $(this).val()
        }
    })
    if (!isNaN(tscore)) {
        $('#asmtScore').text(Number(tscore.toFixed(2)));
    } else {
        $('#asmtScore').text(tscore);
    }
    if (tval) {
        $('#asmtScore').val(tval)
    }
    SdsAsmt.asmtScore = tscore;
    SdsAsmt.asmtLevel = judgeLevel(tscore);
    var clazz = returnLevelClass(SdsAsmt.asmtLevel);
    if (SdsAsmt.asmtLevel != "") {
        $('#asmtResult').text("(" + SdsAsmt.asmtLevel + ")").removeClass().addClass(clazz);
    }
}

/**
 * 获取对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
SdsAsmt.get = function (key, type) {
    var res = "";
    switch (type) {
        case "checkbox":
            $("input[type='checkbox'][name=" + key + "]:checked").each(function () {
                //  选中复选框中的值
                res += $(this).val() + ",";
            });
            res = res.substring(0, res.length - 1)
            break;
        case "radio":
            var obj = $("input[type='radio'][name=" + key + "]:checked");
            res = obj.val();
            break;
        default:
            res = $("input[name=" + key + "]").val();
            break;
    }
    return res;
};

/**
 * 加载评估字典信息
 */
function loadAsmtInfo(){
    var param = {};
    var ajax = new $ax("/api/sdstool/getAsmtInfo", function (res) {
        SdsAsmt.asmtInfo = res;
        loadAsmtItem();
    }, function () {
    });
    param.patientId = $("#patientId").val();
    param.entityId = $("#entityId").val();
    param.asmtId = $("#asmtId").val();
    ajax.set(param);
    ajax.start();
}

/**
 * 展示条目
 */
function loadAsmtItem(){
    var listHtml="";
    //初始化分值
    $('#asmtScore').text('');
    //动态生成评分表html
    var listHtml=listHtml+'<div>';
    var asmtItems = SdsAsmt.asmtInfo.asmtItems;
    var IComb = SdsAsmt.asmtInfo.asmtItems[0].showStyle;//1 竖分；2横分；3横分独表
    var sheetCode=SdsAsmt.asmtInfo.asmtItems[0].sheetCode;
    var itemlen=asmtItems.length;
    var itemPWidth='200px';
    if (itemlen==1) itemPWidth='98%';  //唯一评分项  展开全部
    var listHtml=listHtml+'<div>';
    var itemhtml="";
    var HCount=0; //加载行div
    var itemCount=0; //默认列数
    for (var xind=0;xind<itemlen;xind++) {
        var xitem=asmtItems[xind];
        var itemid=xitem.itemId;
        var itemcode=xitem.itemCode;
        var itemdesc=xitem.itemDesc;
        var multiple=xitem.multipleChoice?true:false;
        //从代码处理当前项目位置信息
        var xitemcode=itemcode.replace(sheetCode,"");
        var xitemcodeArr	= xitemcode.split('-');
        var xhcount			= xitemcodeArr[1];   //行位置
        var xvcount			= xitemcodeArr[2];	//列位置
        var xstyle			= xitemcodeArr[3];	//合并样式
        if (xhcount!=HCount) {
            itemCount=1; //默认一行一列
            if (HCount>0) {
                //给上一个div加上结束标签
                var itemhtml=itemhtml+'</div>';
            }
            if (IComb==3){
                var itemhtml=itemhtml+'<div class="item-h3" id="hdiv'+xhcount+'">';
            }else{
                var itemhtml=itemhtml+'<div class="item-h" id="hdiv'+xhcount+'">';
            }
            HCount=xhcount;
            //新写入一行前，计算总列数
            for (var yind=xind+1;yind<itemlen;yind++) {
                var yitem=asmtItems[yind];
                var yitemcode=yitem.itemCode;
                var yitemcode=yitemcode.replace(sheetCode,"");
                var yitemcodeArr	= yitemcode.split('-');
                var yhcount			= yitemcodeArr[1];   //行位置
                if (yhcount!=xhcount) break;
                var yvcount			= yitemcodeArr[2];	//列位置
                if (yvcount>0) itemCount=yvcount;
            }

        }
        if (itemCount==0) continue;
        var itemDics = xitem.itemDics;
        var itemdicLen=itemDics.length;
        if (IComb==3) {
            //横分表构建
            //第一个评分项构建评分表头
            var titlehtml="",dichtml="";
            if (xind==0) {
                //计算列宽
                var colWidth=99/(itemdicLen+1)+"%";
                //补项目分类头
                var titlehtml=titlehtml+'<div class="dic-title" style="width:'+colWidth+'">'+"项目"+'</div>';
                var dichtml='<div data-multiple='+multiple+'><div class="dic-title3" style="width:'+colWidth+'">'+itemdesc+'</div>';
                for (var dind=0;dind<itemdicLen;dind++) {
                    var xitemdic=itemDics[dind];
                    var EDRowID	= xitemdic.dicId;
                    var EDCode	= xitemdic.dicCode;
                    var EDDesc	= xitemdic.dicDesc;
                    var EDScore	= xitemdic.dicScore;
                    var EDType	= xitemdic.type;
                    var EDExp	= xitemdic.formula;
                    var EDGroup	= xitemdic.mutexFlag;
                    var EDLink	= xitemdic.relationFlag;
                    var titlehtml=titlehtml+'<div class="dic-title" style="width:'+colWidth+'">'+EDScore+'</div>';
                    var dichtml=dichtml+'<div id='+EDRowID+' class="dic-desc" data-calc="'+EDExp+'"  data-score="'+EDScore+'" data-link="'+EDLink+'" data-group="'+EDGroup+'" style="width:'+colWidth+';">'+EDDesc+'</div>';
                }
                var dichtml=dichtml+'</div>';
                titlehtml='<div style="margin-top:10px;" class="item-h3" id="hdiv'+0+'">'+titlehtml+'</div>';
                dichtml='<div class="item-h3" id="hdiv'+1+'">'+dichtml+'</div>';
                itemhtml=titlehtml+dichtml
            }else {
                var dichtml='<div data-multiple='+multiple+'><div class="dic-title3" style="width:'+colWidth+'">'+itemdesc+'</div>';
                for (var dind=0;dind<itemdicLen;dind++) {
                    var xitemdic=itemDics[dind];
                    var EDRowID	= xitemdic.dicId;
                    var EDCode	= xitemdic.dicCode;
                    var EDDesc	= xitemdic.dicDesc;
                    var EDScore	= xitemdic.dicScore;
                    var EDType	= xitemdic.type;
                    var EDExp	= xitemdic.formula;
                    var EDGroup	= xitemdic.mutexFlag;
                    var EDLink	= xitemdic.relationFlag;
                    var dichtml=dichtml+'<div id='+EDRowID+' code='+EDCode+' class="dic-desc" data-calc="'+EDExp+'"  data-score="'+EDScore+'" data-link="'+EDLink+'" data-group="'+EDGroup+'" style="width:'+colWidth+';">'+EDDesc+'</div>';
                }
                var dichtml=dichtml+'</div>';
                itemhtml=itemhtml+dichtml;
            }
        }else if(IComb==2){
            var itemWidth=99/itemCount+"%";
            var itemhtml=itemhtml+'<div class="item-panel" data-multiple='+multiple+' style="width:'+itemWidth+';">';
            var itemhtml=itemhtml+'<div class="dic-title">'+itemdesc+'</div>';
            var itemdicLen=itemDics.length;
            for (var dind=0;dind<itemdicLen;dind++) {
                var xitemdic=itemDics[dind];
                var EDRowID	= xitemdic.dicId;
                var EDCode	= xitemdic.dicCode;
                var EDDesc	= xitemdic.dicDesc;
                var EDScore	= xitemdic.dicScore;
                var EDType	= xitemdic.type;
                var EDExp	= xitemdic.formula;
                var EDGroup	= xitemdic.mutexFlag;
                var EDLink	= xitemdic.relationFlag;
                var EDDesc=EDDesc.replace(/\r\n/g,"<br>");
                var itemhtml=itemhtml+'<div id='+EDRowID+' code='+EDCode+' class="dic-desc" data-calc=\"'+EDExp+'\"  data-score=\"'+EDScore+'\" data-link=\"'+EDLink+'\" data-group=\"'+EDGroup+'\" style="float:left;width:98%;height:100%;">'+EDDesc+'</div>';
                var itemhtml=itemhtml+'<div style="clear:both"></div>';
            }
            var itemhtml=itemhtml+'</div>';
        }else{
            var itemWidth=99/itemCount+"%";
            var itemhtml=itemhtml+'<div class="item-panel" data-multiple='+multiple+' style="width:'+itemWidth+';">';
            var itemhtml=itemhtml+'<div class="dic-title">'+itemdesc+'</div>';
            var itemdicLen=itemDics.length;
            for (var dind=0;dind<itemdicLen;dind++) {
                var xitemdic=itemDics[dind];
                var EDRowID	= xitemdic.dicId;
                var EDCode	= xitemdic.dicCode;
                var EDDesc	= xitemdic.dicDesc;
                var EDScore	= xitemdic.dicScore;
                var EDType	= xitemdic.type;
                var EDExp	= xitemdic.formula;
                var EDGroup	= xitemdic.mutexFlag;
                var EDLink	= xitemdic.relationFlag;
                var EDDesc=EDDesc.replace(/\r\n/g,"<br>");
                // var EDDesc=EDDesc.replace(/\s/g,"<br>");
                /*
                <input id="huodongdu" placeholder="8度=1分，最高18分">
                <div>每5度外翻<input id="waifandu">度</div>
                */
                var itemhtml=itemhtml+'<div class="dic-score">'+EDScore+'</div>';
                if (EDType=="input") {
                    if (EDExp=="") {
                        var itemhtml=itemhtml+'<div style="float:left;"><input id='+EDRowID+' class="dic-input" placeholder='+EDDesc+'></div>';
                    }else{
                        var itemhtml=itemhtml+'<div style="float:left;">'+EDDesc+'<input id='+EDRowID+' data-calc=\"'+EDExp+'\" class="dic-input"></div>';
                    }
                }else{
                    var itemhtml=itemhtml+'<div id='+EDRowID+' code='+EDCode+' class="dic-desc" data-calc=\"'+EDExp+'\"  data-score=\"'+EDScore+'\" data-link=\"'+EDLink+'\" data-group=\"'+EDGroup+'\" >'+EDDesc+'</div>';
                }
                var itemhtml=itemhtml+'<div style="clear:both"></div>';
            }
            var itemhtml=itemhtml+'</div>';
        }

    }
    var listHtml=listHtml+itemhtml;
    var listHtml=listHtml+'</div>';  //最后一个行div结束
    var listHtml=listHtml+'</div></div>';
    $(".evalItemBlock").html(listHtml);
    $.parser.parse(".evalItemBlock");  //解析radio
    //选中div时 计算分值
    $('.dic-desc').on('click',function(){
        //如果容器标记为单选，则先移除所有选中，再选中当前
        if ($(this).parent().attr('data-multiple')=='false') {
            if ($(this).hasClass('dic-desc-selected')) {
                $(this).parent().find('.dic-desc-selected').removeClass('dic-desc-selected');
            }else {
                $(this).parent().find('.dic-desc-selected').removeClass('dic-desc-selected');
                $(this).addClass('dic-desc-selected');
            }
        }else{
            //如果容器标记为多选，则当前切换选中状态
            $(this).toggleClass('dic-desc-selected');
        }
        //搜索父容器下所有互斥项，取消所有互斥项的选中状态
        if ($(this).hasClass('dic-desc-selected')) {
            var selectedText=$(this).text();
            var groupinfo=$(this).attr('data-group');
            var linkinfo=$(this).attr('data-link');
            if (groupinfo) {
                //清除同分组信息下的其他选项
                $('div[data-group='+groupinfo+']').each(function(i, v){
                    if (selectedText!=$(this).text()) {
                        $(this).removeClass('dic-desc-selected');
                    }
                })
            }
            if (linkinfo) {
                //选中相关联的其他选项
                $('div').find('.dic-desc-selected').removeClass('dic-desc-selected');
                $('div[data-link='+linkinfo+']').each(function(i, v){
                    $(this).addClass('dic-desc-selected');
                })
            }
        }
        calVal(sheetCode);
    })
    //输入框计算到总分值
    $('.dic-input').on('input',function(){
        calVal(sheetCode);
    })

    var levelArr = SdsAsmt.asmtInfo.levelRange;
    var levelInfo = "";
    for(var i=0;i<levelArr.length;i++){
        var minValue = parseInt(levelArr[i].minVal);
        var maxValue = parseInt(levelArr[i].maxVal);
        var levelDesc = levelArr[i].level;
        levelInfo += levelDesc + ":" + minValue + "-" + maxValue + "/";
    }

    var asmtNodeMap = SdsAsmt.asmtInfo.asmtNodeMap;
    if (asmtNodeMap != undefined&&asmtNodeMap.length>0&&asmtNodeMap[0] !=null) {
        SdsAsmt.hasNodeFlag = 1;
        $("#nodeType").combobox({
            data:asmtNodeMap,
            valueField:'nodeId',
            textField:'nodeDesc',
            defaultFilter: 6
        })
    } else {
        $("#nodeType").parent().hide();
    }
}


/**
 * 关闭弹窗
 */
SdsAsmt.close = function () {
    parent.postMessage("close", "*");
}

SdsAsmt.print = function () {
    var ajax = new $ax("/api/sdstool/getPrintInfo", function (data) {
        var LODOP = getLodop();
        LODOP.PRINT_INIT("Padua血栓风险因素评估表单");

        var listHtml = "";
        var listHtml = listHtml + '<table border=1 width="97%" cellspacing="0" cellpadding="0" style="border-collapse:collapse" bordercolor="#000000">';
        var listHtml = listHtml + '<caption><b style="font-size: 24px;">' + data.hosp + '</b></caption>';
        var listHtml = listHtml + '<caption><b style="font-size: 18px;">' + data.asmtName + '</b></caption>';
        var itemlen = data.asmtItems.length;

        if (SdsAsmt.evalNode != "") {
            var listHtml = listHtml + '<tr>\n' +
                '                <td width="100%" colspan="' + itemlen + '" style="text-align:left;"><span style="font-weight:bold">节点名称：' + SdsAsmt.evalNode + '</span></td>\n' +
                '            </tr>';
        }
        var listHtml = listHtml + '<tr>\n' +
            '                <td width="100%" colspan="' + itemlen + '" style="text-align:left;">\n' +
            '                    <span style="font-weight:bold">患者姓名：</span>' + data.patientName + '\n' +
            '                    <span style="font-weight:bold">性别：</span>' + data.patientGender + '\n' +
            '                    <span style="font-weight:bold">年龄：</span>' + data.patientAge + '岁\n' +
            '                    <span style="font-weight:bold">病案号：</span>' + data.patientMrNum + '\n' +
            '                </td>\n' +
            '            </tr>';
        var listHtml = listHtml + ' <tr>\n' +
            '                <td width="100%" colspan="' + itemlen + '" style="text-align:left;">\n' +
            '                    <span style="font-weight:bold">入院科室：</span>' + data.admLocDesc + '\n' +
            '                    <span style="font-weight:bold">入院日期：</span>' + data.admDate + '\n' +
            '                </td>\n' +
            '            </tr>';
        var listHtml = listHtml + '<tr>';
        var desc = $("#desc").val();
        // var listHtml=listHtml+'<td width="10%" style="text-align:center;vertical-align:middle;">'+desc+'</td>';

        if (itemlen == 1) {
            var itemPWidth = '90%';
        } else {
            var itemPWidth = 90 / itemlen + '%';
        }
        for (var xind = 0; xind < itemlen; xind++) {
            var xitem = data.asmtItems[xind];
            var itemScoreText = xitem.dicScore + "项";
            var listItem1 = '<span style="font-weight:bold">' + itemScoreText + '</span>';
            var yitem = xitem.itemDics;
            var itemdicLen = yitem.length;
            var listItem2 = "";
            var selectedItems = data.selectedItems;
            var slen = selectedItems.length;
            for (var dind = 0; dind < itemdicLen; dind++) {
                var selectedFlag = false;
                for (var sind = 0; sind < slen; sind++) {
                    if (selectedItems[sind].assessmentEntryId == yitem[dind].dicId) {
                        //var listItem2=listItem2 + '&#9745;'+yitem[dind].dicDesc + '<br />';
                        selectedFlag = true;
                    }
                }
                if (selectedFlag) {
                    var listItem2 = listItem2 + '&#9745;' + yitem[dind].dicDesc + '<br />';
                } else {
                    var listItem2 = listItem2 + '&#9633;' + yitem[dind].dicDesc + '<br />';
                }
            }
            var listHtml = listHtml + '<td width="' + itemPWidth + '" style="vertical-align: top;">\n' +
                listItem1 + '<br />\n' +
                listItem2 + '<br />\n' +
                '                </td>';
        }
        var listHtml = listHtml + '</tr>';
        var listHtml = listHtml + '<tr>';
        var listHtml = listHtml + '<td width="100%" colspan="' + itemlen + '" style="text-align:left;">\n' +
            '                    <span style="font-weight:bold">评估分值：</span>' + SdsAsmt.asmtScore + '\n';
        if (SdsAsmt.asmtLevel != "") {
            var listHtml = listHtml + '                    <span style="font-weight:bold">风险等级：</span>' + SdsAsmt.asmtLevel + '\n';
        }
        var listHtml = listHtml + '                </td>';
        var listHtml = listHtml + '</tr>';
        var listHtml = listHtml + '<tr>';
        var listHtml = listHtml + '<td width="100%" colspan="' + itemlen + '" style="text-align:left;">\n' +
            '                    <span style="font-weight:bold">审核人：</span>' + data.evalUpdateUser + '\n' +
            '                    <span style="font-weight:bold">审核日期：</span>' + data.evalUpdateDate + '\n' +
            '                </td>';
        var listHtml = listHtml + '</tr>';

        var listHtml = listHtml + " </table>";
        $("#Form").html(listHtml);


        LODOP.ADD_PRINT_HTM("10mm", "5mm", "100%", "100%", document.getElementById("Form").innerHTML);

        LODOP.PREVIEW();
    }, function (data) {
    });
    var params = {};
    params.patientId = $("#patientId").val();
    params.entityId = $("#entityId").val();
    params.asmtId = $("#asmtId").val();
    params.evalId = SdsAsmt.evalId;
    ajax.set(params);
    ajax.start();

    /*var LODOP = getLodop();
    LODOP.PRINT_INIT("Padua血栓风险因素评估表单");
    LODOP.ADD_PRINT_HTM("10mm", "5mm", "100%", "100%", document.getElementById("Form").innerHTML);

    LODOP.PREVIEW();*/

}

function getAutoNodeInfo(){
    $('span.auto').remove();

    $('div').find('.dic-desc-selected').removeClass('dic-desc-selected');
    var ajax = new $ax("/api/sdstool/getAutoNodeInfo", function (data) {
        var l = data.length;
        for (let i = 0; i < data.length; i++) {
            var itemId = data[i].assessmentEntryId;
            $("#"+itemId).addClass("dic-desc-selected");
            var x = "<span id="+data[i].id+" class='auto' style='position: absolute;right: 100px;'>A</span>";
            document.getElementById(itemId).innerHTML += x;
            getItemKeyFrom("", data[i].id);
        }
    }, function (data) {
    });
    var params = {};
    params.patientId = $("#patientId").val();
    params.entityId = $("#entityId").val();
    params.asmtId = $("#asmtId").val();
    ajax.set(params);
    ajax.start();
}

/**
 * 返回等级信息Class 颜色区分
 */
function returnLevelClass(levelName) {
    var clazz = "";
    switch (levelName) {
        case "极低危":
            clazz = "vlowRisk";
            break;
        case "低危":
        case "低度可能":
            clazz = "lowRisk";
            break;
        case "中危":
        case "中度可能":
            clazz = "mhighRisk";
            break;
        case "高危":
        case "高度可能":
            clazz = "highRisk";
            break;
        case "极高危":
            clazz = "vhighRisk";
            break;
        default:
            clazz = "vlowRisk";
            break;
    }
    return clazz;
}

$(function () {
    if ($("#asmId").val() == 0) {
        $(".evalDiv").html("<div style='color: grey'>未关联评估(评价)表</div>");
    } else {
        //获取历史评估信息
        loadAsmtNodes();
        //获取评估字典信息
        loadAsmtInfo();
    }
});